;#############################
;命令：
;nasm -f elf64 day1_1if.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;Y is greater than x
;#############################
extern printf

section .data
	x: dd 24
	y: dd 13
	msg1: db "X is greater than y", 10, 0
	msg2: db "Y is greater than x", 10, 0

section .text
	global main

main:
	push rbp
	mov rbp, rsp

	;if (x > y) {
	;  printf("X is greater than y\n");
	;} else {
	;  printf("Y is greater than x\n");
	;}
	;请注意：不可使用rax和rbx
	mov eax, dword [x]
	mov ebx, dword [y]

;##########################################
	;if判定成功了要写在下面
	;这是汇编语言的特色
	;否则else部分没法避开if部分去执行
	cmp eax, ebx
	jg XGreatThanY
	mov rdi, msg2                                   ;else
	jmp end

XGreatThanY:
	mov rdi, msg1                                   ;if

end:
	call printf

;##########################################

	mov eax, 0
	leave
	ret
